package edu.kit.aifb.lidasora.ppmModel;

import java.util.Random;

public class DataExampleCreator {
	
	private String[] stringSets;
	
	private int maxlength;
	
	private Random rng = new Random();
	
	private static final String[] domains = new String[]{"de", "edu", "com", "ca", "ch", "fr", "it", "gov", "co.uk"};
	
	public static final String TEST_INSTANCE = "LINKED DATA QUERY PROCESSING IS COOL";
	
	public static int maxTestInstanceCount = 0;
	
	public DataExampleCreator(int nrBasicStrings, int stringSetSize, int maxlength) {
		String[] basicStrings = new String[nrBasicStrings];
		stringSets = new String[stringSetSize];
		this.maxlength = maxlength;
		
		
		for(int j =0; j < nrBasicStrings; j++) {
			for (int i = 0; i < rng.nextInt(8) + 2; i++) {
				basicStrings[j] += (char) (rng.nextInt(26) + 97);
			}
		}
		
		for(int i = 0; i < stringSets.length; i++) {
			
			int upperBound = rng.nextInt(13) + 2;
			stringSets[i] = "http:/";
			for(int j = 0; j < upperBound; j++) {
				if(j!=1) {
					stringSets[i]+= "/" + basicStrings[rng.nextInt(basicStrings.length)];
				} else {
					stringSets[i]+="." + domains[rng.nextInt(domains.length)].toString();
				}
			}
			
			
			
		}
		
	}
	
	public String[] getToyData (){
		String[] result = new String[maxlength];
		
		for (int i = 0; i < result.length; i++) {
			if (i < 4) {
				result[i] = TEST_INSTANCE;
				DataExampleCreator.maxTestInstanceCount++;
			} else 
				result[i] = stringSets[rng.nextInt(stringSets.length)];
		}
		
		return result;
	}
}
